﻿namespace GLWrap.SceneObjects.Line
{
    public class FullfilledLine: BaseLine
    {
        private BaseLine _line;
        private readonly Sphere _pointASphere;
        private readonly Sphere _pointBSphere;

        public BaseLine Line
        {
            get { return _line; }
            set
            {
                _line = value;
                MarkAsDirty();
            }
        }

        public override float Weight
        {
            get
            {
                return _weight;
            }
            set
            {
                _weight = value;
                _line.Weight = _weight;
                _pointASphere.Radius = _weight;
                _pointBSphere.Radius = _weight;
            }
        }

        public FullfilledLine():this(new SimpleLine())
        {
            
        }

        public FullfilledLine(BaseLine line)
        {
            _line = line;
            _pointASphere = new Sphere() { Radius = line.Weight };
            _pointBSphere = new Sphere() { Radius = line.Weight };

            AttachObject(_line);
            AttachObject(_pointASphere);
            AttachObject(_pointBSphere);
        }

        protected override void InternalRecalculateLineForSceneManager(GlSceneManager sceneManager)
        {
            _line.PointA = PointA;
            _line.PointB = PointB;
            _pointASphere.Position = PointA;
            _pointBSphere.Position = PointB;
        }
    }
}
